package com.yh.tea.controller;


import com.yh.tea.configration.MinioConfig;
import com.yh.tea.utiity.MinioUtil;
import com.yh.tea.utiity.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@Api(tags = "上传相关接口")
@RequestMapping("/file")
@CrossOrigin
public class FilesController {
    @Resource
    private MinioUtil minioUtil;

    @PostMapping("/upload")
    @ApiOperation("添加图片")
    public ResponseResult uploadImg(@RequestPart MultipartFile file) throws Exception {
        System.out.println("dddd");
        String pathUrl = minioUtil.upload(file,"images");
        return ResponseResult.success("上传成功",pathUrl);
    }

}
